﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;


namespace YS.Domain.IoT.Receive
{
    public class RequestInfo : IRequestInfo
    {
        public RequestInfo() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="key"></param>
        /// <param name="mid"></param>
        /// <param name="eventId"></param>
        /// <param name="version"></param>
        /// <param name="body"></param>
        /// <param name="sign"></param>
        public RequestInfo(string key, string mid, string eventId,string messageId, string version, string body, string sign, string clientId)
        {
            Key = key;
            Mid = mid;
            EventId = eventId;
            MessageId = messageId;
            Version = version;
            Body = body;
            Sign = sign;
            ClientId = clientId;
            if (!string.IsNullOrEmpty(Body))
            {
                MainInfo = Body.FromJsonString<BaseCmd>();
            }
            else
            {
                MainInfo = new BaseCmd();
            }

        }
        /// <summary>
        ///客户端Id
        /// </summary>
        public string ClientId { get; private set; }
        /// <summary>
        ///协议号
        /// </summary>
        public string Key { get; private set; }
        /// <summary>
        ///设备号
        /// </summary>
        public string Mid { get; private set; }
        /// <summary>
        ///事件Id
        /// </summary>
        public string EventId { get; private set; }
        /// <summary>
        /// 消息Id
        /// </summary>
        public string MessageId { get; set; }
        /// <summary>
        ///版本号
        /// </summary>
        public string Version { get; private set; }
        /// <summary>
        /// 消息内容
        /// </summary>
        public string Body { get; private set; }

        public BaseCmd MainInfo { get; private set; }
        /// <summary>
        /// 签名
        /// </summary>
        public string Sign { get; private set; }

    }
    public struct KeyGroup
    {
        public string Key { get; set; }
        public string Version { get; set; }
        public string CommandId { get; set; }
        public int ConvertType { get; set; }
        public string Mid { get; set; }
    }

    public class VMCLoginCmd : BaseCmd
    {
        public string MidInfo { get; set; } = string.Empty;
    }
    public class BaseCmd
    {
        public string Mid { get; set; } = "0000000000";


        public long TimeSp { get; set; } = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();

    }
}
